﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using SnakeWalk.Utils;

namespace SnakeWalk
{
    public class Snake
    {
        public List<Body> SnakeBodies { get; set; }

        public Snake(int countbody)
        {
            SnakeBodies = new List<Body>(countbody);
        }

        public void Move(DirectionSnake Direction)
        {
            // Head Snake
            Body headBody = SnakeBodies[0];

            // Move Body
            for (int i = SnakeBodies.Count - 1; i > 0 ; i--)
            {
                SnakeBodies[i].Position = new SWPosition(SnakeBodies[i - 1].Position);
            }

            switch (Direction)
            {
                case DirectionSnake.Up:
                    headBody.Position.Y -= (int)SizeAndBaitSnake.Height;
                    break;
                case DirectionSnake.Down:
                    headBody.Position.Y += (int)SizeAndBaitSnake.Height;
                    break;
                case DirectionSnake.Left:
                    headBody.Position.X -= (int)SizeAndBaitSnake.Width;
                    break;
                case DirectionSnake.Right:
                    headBody.Position.X += (int)SizeAndBaitSnake.Width;
                    break;
                default:
                    break;
            }
        }
    }
}
